package com.group.service.impl.change;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.group.service.change.ChangeRecordServiceI;
import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
import com.group.entity.change.ChangeRecordEntity;
import java.util.UUID;
import java.io.Serializable;

@Service("changeRecordService")
@Transactional
public class ChangeRecordServiceImpl extends CommonServiceImpl implements ChangeRecordServiceI {

	
 	public <T> void delete(T entity) {
 		super.delete(entity);
 		//执行删除操作配置的sql增强
		this.doDelSql((ChangeRecordEntity)entity);
 	}
 	
 	public <T> Serializable save(T entity) {
 		Serializable t = super.save(entity);
 		//执行新增操作配置的sql增强
 		this.doAddSql((ChangeRecordEntity)entity);
 		return t;
 	}
 	
 	public <T> void saveOrUpdate(T entity) {
 		super.saveOrUpdate(entity);
 		//执行更新操作配置的sql增强
 		this.doUpdateSql((ChangeRecordEntity)entity);
 	}
 	
 	/**
	 * 默认按钮-sql增强-新增操作
	 * @param id
	 * @return
	 */
 	public boolean doAddSql(ChangeRecordEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-更新操作
	 * @param id
	 * @return
	 */
 	public boolean doUpdateSql(ChangeRecordEntity t){
	 	return true;
 	}
 	/**
	 * 默认按钮-sql增强-删除操作
	 * @param id
	 * @return
	 */
 	public boolean doDelSql(ChangeRecordEntity t){
	 	return true;
 	}
 	
 	/**
	 * 替换sql中的变量
	 * @param sql
	 * @return
	 */
 	public String replaceVal(String sql,ChangeRecordEntity t){
 		sql  = sql.replace("#{id}",String.valueOf(t.getId()));
 		sql  = sql.replace("#{user_mobile}",String.valueOf(t.getUserMobile()));
 		sql  = sql.replace("#{applicants_new}",String.valueOf(t.getApplicantsNew()));
 		sql  = sql.replace("#{inventors_new}",String.valueOf(t.getInventorsNew()));
 		sql  = sql.replace("#{order_state}",String.valueOf(t.getOrderState()));
 		sql  = sql.replace("#{official_amount}",String.valueOf(t.getOfficialAmount()));
 		sql  = sql.replace("#{agent_amount}",String.valueOf(t.getAgentAmount()));
 		sql  = sql.replace("#{order_amount}",String.valueOf(t.getOrderAmount()));
 		sql  = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
 		sql  = sql.replace("#{create_person}",String.valueOf(t.getCreatePerson()));
 		sql  = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
 		sql  = sql.replace("#{update_person}",String.valueOf(t.getUpdatePerson()));
 		sql  = sql.replace("#{valid_flag}",String.valueOf(t.getValidFlag()));
 		sql  = sql.replace("#{trans_no}",String.valueOf(t.getTransNo()));
 		sql  = sql.replace("#{paid_time}",String.valueOf(t.getPaidTime()));
 		sql  = sql.replace("#{order_no}",String.valueOf(t.getOrderNo()));
 		sql  = sql.replace("#{UUID}",UUID.randomUUID().toString());
 		return sql;
 	}
}